<%--
  Created by IntelliJ IDEA.
  User: gsb
  Date: 2019/11/22
  Time: 18:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>抽题规则</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/css/attend/m/common.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/eleTree.css">
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/layui/layui/layui.js"></script>
    <script src="/lib/layui/layui/js/common.js" type="text/javascript" charset="utf-8"></script>
    <script src="/ui/lib/layui/layui/js/baseCode/base.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .layui-form-label{width:100px;}
        .layui-input-block{margin-left:130px;}
        .layui-disabled, .layui-disabled:hover{color: #797979 !important;}
        .layui-treeSelect .ztree li span.button.root_close{
            background-image: url(/css/zTreeStyle/img/zTreeStandard.png)!important;
            background-position: -74px -54px!important;
        }
        .layui-treeSelect .ztree li span.button.root_open{
            background-image: url(/css/zTreeStyle/img/zTreeStandard.png)!important;
            background-position: -92px -54px!important;
        }
    </style>
    <link rel="stylesheet" href="/css/zTreeStyle/zTreeStyle.css"/>
    <%--    <link rel="stylesheet" href="/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css"/>--%>
    <%--    <script type="text/javascript" src="/lib/zTree_v3/js/jquery.ztree.all.min.js"></script>--%>


<body>
<div>
    <!--
 自定义布局表单控件
 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body" style="padding: 15px;">
                <form class="layui-form form" action="" lay-filter="qaForm">
                    <div id="view">

                        <div class="layui-form-item">
                            <label class="layui-form-label">所属目录<span style="color: red">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" name="" id="tree" lay-filter="tree" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                                <input type="hidden" name="testId" id="testId" class="layui-input">
                                <input type="hidden" name="testName" id="testName" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                                <label class="layui-form-label" style="">难度类型<span style="color: red">*</span></label>
                                <div class="layui-input-block" >
                                    <select name="eqType" lay-verify="required">
                                        <option value="">请选择</option>
                                        <option value="1">简单</option>
                                        <option value="2">中等</option>
                                        <option value="3">困难</option>
                                    </select>
                                </div>

                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">抽题数量<span style="color: red">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" name="num" required  lay-verify="required" placeholder="请输入抽题数量" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var type = $.GetRequest().type;
        var num = $.GetRequest().num||'';
        var eqType = $.GetRequest().eqType||'';
        var testId = $.GetRequest().testId||'';
        var testName = decodeURI($.GetRequest().testName)||'';
        layui.use(['form','layer','treeSelect'],function(){
            var $ = layui.jquery,
                form = layui.form,
                layer = layui.layer,
                treeSelect = layui.treeSelect;

            form.render();
            //下拉樹獲取
            function treeSelects(treeId,id){
                treeSelect.render({
                    elem: treeId,     // 选择器
                    data: '/tbExamList/selectAllTree?sortId=0',  // 数据
                    type: 'get',      // 异步加载方式：get/post，默认get
                    placeholder: '请选择',   // 占位符
                    check: 'checkbox',
                    search: true,  // 是否开启搜索功能：true/false，默认false
                    style: {   // 一些可定制的样式
                        folder: {enable: true},
                        line: {enable: true}
                    },
                    click: function(d){     // 点击回调
                        $('input[name="testId"]').val(d.current.id);
                        $('input[name="testName"]').val(d.current.name);
                        form.render()
                    },
                    // 加载完成后的回调函数
                    success: function (d) {
                        // $('.layui-treeSelect .layui-select-title').append('<div style="position: absolute;top:0px;width:95%" class="layui-input multiSelect"></div>')
                        if(id!=''&&id!=undefined){
                            var treeId = $('.layui-treeSelect-body').attr('id')
                            treeSelect.checkNode('#tree',treeId,id);
                            if(testId!=''&&testId!='undefined'){
                                $('input[name="testId"]').val(testId);
                            }
                            if(testName!=''&&testName!='undefined'){
                                $('input[name="testName"]').val(testName);
                            }

                        }
                        form.render();
                    }
                });
            }
            //获取详情

            if(type=='edit'){

                $('[name="eqType"]').val(eqType)
                $('[name="num"]').val(num)
                form.render('select');
                treeSelects('#tree',testId)
                form.render();

            }else{
                treeSelects('#tree','')
            }
        });

    </script>
</div>
<style>
    .layui-form-checkbox i{
        border-left: 1px solid #d2d2d2;
    }
    .active{
        display: block;
    }
    .nonactive{
        display: none;
    }
</style>
</body>
</html>
